package com.warm.redis.config;

import com.warm.redis.JsonSerializer;
import com.warm.redis.RedisCacheService;
import org.noear.redisx.RedisClient;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.cache.jedis.RedisClientSupplier;
import org.noear.solon.data.cache.CacheService;

/**
 * 缓存配置
 *
 * @author warm
 */
@Configuration
public class RedisConfig {

    @Bean(value = "cache1", typed = true)// 默认
    public CacheService cache1(@Inject("${warm.cache1}") RedisCacheService cache) {
        cache.serializer(new JsonSerializer());
        return cache;
    }

    @Bean
    public RedisClient redisClient(@Inject("${warm.cache1}") RedisClientSupplier clientSupplier) {
        return clientSupplier.get();
    }

}
